
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Corpus Reader Methods &#8212; PyCantonese 2.2.0 documentation</title>
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Jyutping Romanization: Parsing and Conversion" href="jyutping.html" />
    <link rel="prev" title="Stop Words" href="stop_words.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="jyutping.html" title="Jyutping Romanization: Parsing and Conversion"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="stop_words.html" title="Stop Words"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">PyCantonese 2.2.0 documentation</a> &#187;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Corpus Reader Methods</a><ul>
<li><a class="reference internal" href="#the-representation-of-words">The Representation of “Words”</a></li>
<li><a class="reference internal" href="#a-note-on-the-access-methods">A Note on the Access Methods</a></li>
<li><a class="reference internal" href="#metadata-methods">Metadata Methods</a></li>
<li><a class="reference internal" href="#data-methods">Data Methods</a></li>
<li><a class="reference internal" href="#full-reader-api">Full Reader API</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="stop_words.html"
                        title="previous chapter">Stop Words</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="jyutping.html"
                        title="next chapter">Jyutping Romanization: Parsing and Conversion</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="corpus-reader-methods">
<span id="reader"></span><h1>Corpus Reader Methods<a class="headerlink" href="#corpus-reader-methods" title="Permalink to this headline">¶</a></h1>
<p>The sections <a class="reference internal" href="#represent-words"><span class="std std-ref">The Representation of “Words”</span></a> and <a class="reference internal" href="#note-on-methods"><span class="std std-ref">A Note on the Access Methods</span></a> provide
background information for how to use the methods listed in
<a class="reference internal" href="#metadata-methods"><span class="std std-ref">Metadata Methods</span></a> and <a class="reference internal" href="#data-methods"><span class="std std-ref">Data Methods</span></a>.</p>
<div class="section" id="the-representation-of-words">
<span id="represent-words"></span><h2>The Representation of “Words”<a class="headerlink" href="#the-representation-of-words" title="Permalink to this headline">¶</a></h2>
<p>The representation of “words” in PyCantonese comes in two flavors
(similar to NLTK):</p>
<ol class="arabic">
<li><p class="first">The “simple” representation as a <strong>string</strong>,
which is what appears as a word token (in Chinese characters)
in a transcription line
starting with <code class="docutils literal notranslate"><span class="pre">*</span></code> in the CHAT transcript.</p>
</li>
<li><p class="first">The “tagged” representation as a <strong>tuple</strong> of
(<em>word</em>, <em>pos</em>, <em>jyutping</em>, <em>rel</em>),
which contains information from the transcription line and its <code class="docutils literal notranslate"><span class="pre">%</span></code>-tiers:</p>
<p><em>word</em> (str) – Chinese character(s)</p>
<p><em>pos</em> (str) – part-of-speech tag from <code class="docutils literal notranslate"><span class="pre">%mor</span></code> (All PoS tags are rendered in uppercase.)</p>
<p><em>jyutping</em> (str) – Jyutping romanization from <code class="docutils literal notranslate"><span class="pre">%mor</span></code>
(plus inflectional information, if any)</p>
<p><em>rel</em> – dependency and grammatical relation from <code class="docutils literal notranslate"><span class="pre">%gra</span></code>
(no known datasets have made used of <code class="docutils literal notranslate"><span class="pre">%gra</span></code> yet)</p>
</li>
</ol>
<p>To illustrate, let us consider the following CHAT utterance with its <code class="docutils literal notranslate"><span class="pre">%mor</span></code>
tier:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>*XXA:       喂 遲 啲 去 唔 去 旅行 啊 ?
%mor:       e|wai3 a|ci4 u|di1 v|heoi3 d|m4 v|heoi3 vn|leoi5hang4 y|aa3 ?
</pre></div>
</div>
<p>The list of “simple” words from this utterance are the list of word token
strings:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="s1">&#39;喂&#39;</span><span class="p">,</span> <span class="s1">&#39;遲&#39;</span><span class="p">,</span> <span class="s1">&#39;啲&#39;</span><span class="p">,</span> <span class="s1">&#39;去&#39;</span><span class="p">,</span> <span class="s1">&#39;唔&#39;</span><span class="p">,</span> <span class="s1">&#39;去&#39;</span><span class="p">,</span> <span class="s1">&#39;旅行&#39;</span><span class="p">,</span> <span class="s1">&#39;啊&#39;</span><span class="p">,</span> <span class="s1">&#39;?&#39;</span><span class="p">]</span>
</pre></div>
</div>
<p>The list of “tagged” words from this utterance are a list of 4-tuples:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="p">[(</span><span class="s1">&#39;喂&#39;</span><span class="p">,</span> <span class="s1">&#39;E&#39;</span><span class="p">,</span> <span class="s1">&#39;wai3&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;遲&#39;</span><span class="p">,</span> <span class="s1">&#39;A&#39;</span><span class="p">,</span> <span class="s1">&#39;ci4&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;啲&#39;</span><span class="p">,</span> <span class="s1">&#39;U&#39;</span><span class="p">,</span> <span class="s1">&#39;di1&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;去&#39;</span><span class="p">,</span> <span class="s1">&#39;V&#39;</span><span class="p">,</span> <span class="s1">&#39;heoi3&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;唔&#39;</span><span class="p">,</span> <span class="s1">&#39;D&#39;</span><span class="p">,</span> <span class="s1">&#39;m4&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;去&#39;</span><span class="p">,</span> <span class="s1">&#39;V&#39;</span><span class="p">,</span> <span class="s1">&#39;heoi3&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;旅行&#39;</span><span class="p">,</span> <span class="s1">&#39;VN&#39;</span><span class="p">,</span> <span class="s1">&#39;leoi5hang4&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;啊&#39;</span><span class="p">,</span> <span class="s1">&#39;Y&#39;</span><span class="p">,</span> <span class="s1">&#39;aa3&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">),</span>
 <span class="p">(</span><span class="s1">&#39;?&#39;</span><span class="p">,</span> <span class="s1">&#39;?&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)]</span>
</pre></div>
</div>
<p>The distinction of “simple” versus “tagged” words is reflected in the data
access methods listed in <a class="reference internal" href="#data-methods"><span class="std std-ref">Data Methods</span></a> below.</p>
</div>
<div class="section" id="a-note-on-the-access-methods">
<span id="note-on-methods"></span><h2>A Note on the Access Methods<a class="headerlink" href="#a-note-on-the-access-methods" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">pycantonese</span> <span class="kn">as</span> <span class="nn">pc</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">corpus</span> <span class="o">=</span> <span class="n">pc</span><span class="o">.</span><span class="n">hkcancor</span><span class="p">()</span>
</pre></div>
</div>
<p>A corpus object, such as <code class="docutils literal notranslate"><span class="pre">corpus</span></code> as shown just above, has an array of
methods X(). An example is <code class="docutils literal notranslate"><span class="pre">number_of_files()</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">corpus</span><span class="o">.</span><span class="n">number_of_files</span><span class="p">()</span>
<span class="go">58</span>
</pre></div>
</div>
<p>Many of these methods together with their documentation notes are
programmatically inherited from the library PyLangAcq for
language acquisition research. A few remarks here are necessary to
avoid confusion.</p>
<p>Many methods have the optional parameter <code class="docutils literal notranslate"><span class="pre">participant</span></code>, which may safely be
ignored in PyCantonese. The parameter <code class="docutils literal notranslate"><span class="pre">participant</span></code> specifies
which participant(s) are of interest. This is important in the context of
language acquisition: <code class="docutils literal notranslate"><span class="pre">'CHI'</span></code> for the target child, <code class="docutils literal notranslate"><span class="pre">'MOT'</span></code> for the mother,
and so forth. In the CHAT format of HKCanCor that PyCantonese includes, the
participants are rendered as codes such <code class="docutils literal notranslate"><span class="pre">'XXA'</span></code>, <code class="docutils literal notranslate"><span class="pre">'XXB'</span></code> etc based on
the original HKCanCor files. When <code class="docutils literal notranslate"><span class="pre">participant</span></code> is not specified,
all participants are automatically included.</p>
<p>Another optional parameter of interest is <code class="docutils literal notranslate"><span class="pre">by_files</span></code>. Typically, a corpus
comes in the form of multiple CHAT files. If a method X() has <code class="docutils literal notranslate"><span class="pre">by_files</span></code>,
this parameter is set to be <code class="docutils literal notranslate"><span class="pre">False</span></code> by default, so that X() returns whatever
it is for all the files <em>without</em> the file structure. If you are interested
in results for individual files, set <code class="docutils literal notranslate"><span class="pre">by_files</span></code> to be <code class="docutils literal notranslate"><span class="pre">True</span></code> and the return
object is dict(absolute-path filename: X() for that file) instead.</p>
</div>
<div class="section" id="metadata-methods">
<span id="id1"></span><h2>Metadata Methods<a class="headerlink" href="#metadata-methods" title="Permalink to this headline">¶</a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.filenames" title="pycantonese.corpus.CantoneseCHATReader.filenames"><code class="xref py py-obj docutils literal notranslate"><span class="pre">filenames</span></code></a>([sorted_by_age])</td>
<td>Return the set of absolute-path filenames.</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">find_filename</span></code></td>
<td></td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.number_of_files" title="pycantonese.corpus.CantoneseCHATReader.number_of_files"><code class="xref py py-obj docutils literal notranslate"><span class="pre">number_of_files</span></code></a>()</td>
<td>Return the number of files.</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">number_of_utterances</span></code>(**kwargs)</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="data-methods">
<span id="id2"></span><h2>Data Methods<a class="headerlink" href="#data-methods" title="Permalink to this headline">¶</a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">utterances</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">words</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">tagged_words</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">sents</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">tagged_sents</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.jyutpings" title="pycantonese.corpus.CantoneseCHATReader.jyutpings"><code class="xref py py-obj docutils literal notranslate"><span class="pre">jyutpings</span></code></a>([participant,&nbsp;exclude,&nbsp;by_files])</td>
<td>Return a list of jyutping strings by <em>participant</em> in all files.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.jyutping_sents" title="pycantonese.corpus.CantoneseCHATReader.jyutping_sents"><code class="xref py py-obj docutils literal notranslate"><span class="pre">jyutping_sents</span></code></a>([participant,&nbsp;exclude,&nbsp;by_files])</td>
<td>Return a list of sents of jyutping strings by <em>participant</em> in all files.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.characters" title="pycantonese.corpus.CantoneseCHATReader.characters"><code class="xref py py-obj docutils literal notranslate"><span class="pre">characters</span></code></a>([participant,&nbsp;exclude,&nbsp;by_files])</td>
<td>Return a list of Chinese characters by <em>participant</em> in all files.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.character_sents" title="pycantonese.corpus.CantoneseCHATReader.character_sents"><code class="xref py py-obj docutils literal notranslate"><span class="pre">character_sents</span></code></a>([participant,&nbsp;exclude,&nbsp;by_files])</td>
<td>Return a list of sents of Chinese characters by <em>participant</em> in all files.</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">part_of_speech_tags</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">word_frequency</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">word_ngrams</span></code>(**kwargs)</td>
<td></td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.search" title="pycantonese.corpus.CantoneseCHATReader.search"><code class="xref py py-obj docutils literal notranslate"><span class="pre">search</span></code></a>([onset,&nbsp;nucleus,&nbsp;coda,&nbsp;tone,&nbsp;…])</td>
<td>Search for the specified element(s).</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.update" title="pycantonese.corpus.CantoneseCHATReader.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>(reader)</td>
<td>Combine the current CHAT Reader instance with <code class="docutils literal notranslate"><span class="pre">reader</span></code>.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.add" title="pycantonese.corpus.CantoneseCHATReader.add"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add</span></code></a>(*filenames)</td>
<td>Add one or more CHAT <code class="docutils literal notranslate"><span class="pre">filenames</span></code> to the current reader.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.remove" title="pycantonese.corpus.CantoneseCHATReader.remove"><code class="xref py py-obj docutils literal notranslate"><span class="pre">remove</span></code></a>(*filenames)</td>
<td>Remove one or more CHAT <code class="docutils literal notranslate"><span class="pre">filenames</span></code> from the current reader.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#pycantonese.corpus.CantoneseCHATReader.clear" title="pycantonese.corpus.CantoneseCHATReader.clear"><code class="xref py py-obj docutils literal notranslate"><span class="pre">clear</span></code></a>()</td>
<td>Clear everything and reset as an empty Reader instance.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="full-reader-api">
<span id="reader-api"></span><h2>Full Reader API<a class="headerlink" href="#full-reader-api" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="pycantonese.corpus.CantoneseCHATReader">
<em class="property">class </em><code class="descclassname">pycantonese.corpus.</code><code class="descname">CantoneseCHATReader</code><span class="sig-paren">(</span><em>*filenames</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pylangacq.chat.Reader</span></code></p>
<p>A class for reading Cantonese CHAT corpus files.</p>
<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.IPSyn">
<code class="descname">IPSyn</code><span class="sig-paren">(</span><em>participant='CHI'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.IPSyn" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the file’s IPSyn.</p>
<p>IPSyn = index of productive syntax</p>
<dl class="docutils">
<dt>participant <span class="classifier-delimiter">:</span> <span class="classifier">str, optional</span></dt>
<dd>The specified participant (default to <code class="docutils literal notranslate"><span class="pre">'CHI'</span></code>).</dd>
</dl>
<p>dict(str: int)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.MLU">
<code class="descname">MLU</code><span class="sig-paren">(</span><em>participant='CHI'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.MLU" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the file’s MLU by morphemes.</p>
<p>MLU = mean length of utterance. This method is identical to <code class="docutils literal notranslate"><span class="pre">MLUm</span></code>.</p>
<dl class="docutils">
<dt>participant <span class="classifier-delimiter">:</span> <span class="classifier">str, optional</span></dt>
<dd>The specified participant (default to <code class="docutils literal notranslate"><span class="pre">'CHI'</span></code>).</dd>
</dl>
<p>dict(str: float)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.MLUm">
<code class="descname">MLUm</code><span class="sig-paren">(</span><em>participant='CHI'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.MLUm" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the file’s MLU by morphemes.</p>
<p>MLU = mean length of utterance. This method is identical to <code class="docutils literal notranslate"><span class="pre">MLUm</span></code>.</p>
<dl class="docutils">
<dt>participant <span class="classifier-delimiter">:</span> <span class="classifier">str, optional</span></dt>
<dd>The specified participant (default to <code class="docutils literal notranslate"><span class="pre">'CHI'</span></code>).</dd>
</dl>
<p>dict(str: float)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.MLUw">
<code class="descname">MLUw</code><span class="sig-paren">(</span><em>participant='CHI'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.MLUw" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the file’s MLU by words.</p>
<p>MLU = mean length of utterance.</p>
<dl class="docutils">
<dt>participant <span class="classifier-delimiter">:</span> <span class="classifier">str, optional</span></dt>
<dd>The specified participant (default to <code class="docutils literal notranslate"><span class="pre">'CHI'</span></code>).</dd>
</dl>
<p>dict(str: float)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.TTR">
<code class="descname">TTR</code><span class="sig-paren">(</span><em>participant='CHI'</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.TTR" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the file’s TTR.</p>
<p>TTR = type-token ratio</p>
<dl class="docutils">
<dt>participant <span class="classifier-delimiter">:</span> <span class="classifier">str, optional</span></dt>
<dd>The specified participant (default to <code class="docutils literal notranslate"><span class="pre">'CHI'</span></code>).</dd>
</dl>
<p>dict(str: float)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.abspath">
<code class="descname">abspath</code><span class="sig-paren">(</span><em>basename</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.abspath" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the absolute path of <code class="docutils literal notranslate"><span class="pre">basename</span></code>.</p>
<dl class="docutils">
<dt>basename <span class="classifier-delimiter">:</span> <span class="classifier">str</span></dt>
<dd>The basename (e.g., “foobar.cha”) of the desired data file.</dd>
</dl>
<p>str</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.add">
<code class="descname">add</code><span class="sig-paren">(</span><em>*filenames</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add one or more CHAT <code class="docutils literal notranslate"><span class="pre">filenames</span></code> to the current reader.</p>
<dl class="docutils">
<dt><a href="#id3"><span class="problematic" id="id4">*</span></a>filenames</dt>
<dd>Filenames may take glob patterns with wildcards <code class="docutils literal notranslate"><span class="pre">*</span></code> and <code class="docutils literal notranslate"><span class="pre">?</span></code>.</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.age">
<code class="descname">age</code><span class="sig-paren">(</span><em>participant='CHI'</em>, <em>months=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.age" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the <em>participant</em>’s age.</p>
<p>The age is in the form of (years, months, days).</p>
<dl class="docutils">
<dt>participant <span class="classifier-delimiter">:</span> <span class="classifier">str, optional</span></dt>
<dd>The specified participant</dd>
<dt>months <span class="classifier-delimiter">:</span> <span class="classifier">bool, optional</span></dt>
<dd>If <code class="docutils literal notranslate"><span class="pre">True</span></code>, age is in months.</dd>
</dl>
<p>dict(str: tuple(int, int, int)) or dict(str: float)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.character_sents">
<code class="descname">character_sents</code><span class="sig-paren">(</span><em>participant=None</em>, <em>exclude=None</em>, <em>by_files=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.character_sents" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of sents of Chinese characters
by <em>participant</em> in all files.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>participant</strong> – Specify the participant(s); defaults to all
participants.</li>
<li><strong>by_files</strong> – If True (default: False), return dict(absolute-path
filename: X for that file) instead of X for all files altogether.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list(list(str)), or dict(str: list(list(str)))</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.characters">
<code class="descname">characters</code><span class="sig-paren">(</span><em>participant=None</em>, <em>exclude=None</em>, <em>by_files=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.characters" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of Chinese characters by <em>participant</em> in all files.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>participant</strong> – Specify the participant(s); defaults to all
participants.</li>
<li><strong>by_files</strong> – If True (default: False), return dict(absolute-path
filename: X for that file) instead of X for all files altogether.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list(str), or dict(str: list(str))</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear everything and reset as an empty Reader instance.</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.date_of_birth">
<code class="descname">date_of_birth</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.date_of_birth" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the date of birth.</p>
<p>dict(str: dict(str: tuple(int, int, int)))</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.dates_of_recording">
<code class="descname">dates_of_recording</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.dates_of_recording" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the date of recording.</p>
<p>The date of recording is in the form of (year, month, day).</p>
<p>dict(str: list(tuple(int, int, int)))</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.filenames">
<code class="descname">filenames</code><span class="sig-paren">(</span><em>sorted_by_age=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.filenames" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the set of absolute-path filenames.</p>
<dl class="docutils">
<dt>sorted_by_age <span class="classifier-delimiter">:</span> <span class="classifier">bool, optional</span></dt>
<dd>Whether to return the filenames as a list sorted by the target
child’s age.</dd>
</dl>
<p>set of str or list of str</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.headers">
<code class="descname">headers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a dict mapping a file path to the headers of that file.</p>
<p>dict(str: dict)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.index_to_tiers">
<code class="descname">index_to_tiers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.index_to_tiers" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a dict mapping a file path to the file’s index_to_tiers dict.</p>
<p>dict(str: dict)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.jyutping_sents">
<code class="descname">jyutping_sents</code><span class="sig-paren">(</span><em>participant=None</em>, <em>exclude=None</em>, <em>by_files=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.jyutping_sents" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of sents of jyutping strings
by <em>participant</em> in all files.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>participant</strong> – Specify the participant(s); defaults to all
participants.</li>
<li><strong>by_files</strong> – If True (default: False), return dict(absolute-path
filename: X for that file) instead of X for all files altogether.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list(list(str)), or dict(str: list(list(str)))</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.jyutpings">
<code class="descname">jyutpings</code><span class="sig-paren">(</span><em>participant=None</em>, <em>exclude=None</em>, <em>by_files=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.jyutpings" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of jyutping strings by <em>participant</em> in all files.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>participant</strong> – Specify the participant(s); defaults to all
participants.</li>
<li><strong>by_files</strong> – If True (default: False), return dict(absolute-path
filename: X for that file) instead of X for all files altogether.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list(str), or dict(str: list(str))</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.languages">
<code class="descname">languages</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.languages" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a map from a file path to the languages used.</p>
<p>dict(str: list(str))</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.number_of_files">
<code class="descname">number_of_files</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.number_of_files" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the number of files.</p>
<p>int</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.participants">
<code class="descname">participants</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.participants" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a dict mapping a file path to the file’s participant info.</p>
<p>dict(str: dict)</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.remove">
<code class="descname">remove</code><span class="sig-paren">(</span><em>*filenames</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove one or more CHAT <code class="docutils literal notranslate"><span class="pre">filenames</span></code> from the current reader.</p>
<dl class="docutils">
<dt><a href="#id5"><span class="problematic" id="id6">*</span></a>filenames</dt>
<dd>Filenames may take glob patterns with wildcards <code class="docutils literal notranslate"><span class="pre">*</span></code> and <code class="docutils literal notranslate"><span class="pre">?</span></code>.</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.search">
<code class="descname">search</code><span class="sig-paren">(</span><em>onset=None</em>, <em>nucleus=None</em>, <em>coda=None</em>, <em>tone=None</em>, <em>initial=None</em>, <em>final=None</em>, <em>jyutping=None</em>, <em>character=None</em>, <em>pos=None</em>, <em>word_range=(0</em>, <em>0)</em>, <em>sent_range=(0</em>, <em>0)</em>, <em>tagged=True</em>, <em>sents=False</em>, <em>participant=None</em>, <em>exclude=None</em>, <em>by_files=False</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.search" title="Permalink to this definition">¶</a></dt>
<dd><p>Search for the specified element(s).</p>
<p><strong>Jyutping elements</strong></p>
<p>Parameters are <em>onset</em>, <em>nucleus</em>, <em>coda</em>, <em>tone</em>, <em>initial</em>,
<em>final</em>, <em>jyutping</em>.
If <em>jyutping</em> is used, none of the other Jyutping elements can be.
If <em>final</em> is used, neither <em>nucleus</em> nor <em>coda</em> can be.
<em>onset</em> and <em>initial</em> cannot conflict, unless one or both of them are
None.
Regular expression matching applies to
<em>onset</em>, <em>nucleus</em>, <em>coda</em>, <em>tone</em>, and <em>initial</em>.</p>
<p><strong>Chinese character</strong></p>
<p>Parameter: <em>character</em> (only one is allowed)</p>
<p><strong>Part-of-speech tag</strong></p>
<p>Parameter: <em>pos</em></p>
<p>Regular expression matching applies.</p>
<p><strong>Word or sentence range</strong></p>
<p><em>word_range</em>: specify the span of words to the left and right
of a match word; defaults to <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">0)</span></code>.</p>
<p><em>sent_range</em>: specify the span of sents preceding and following
the sent containing a match word; defaults to <code class="docutils literal notranslate"><span class="pre">(0,</span> <span class="pre">0)</span></code>.</p>
<p>If <em>sent_range</em> is used, <em>word_range</em> is ignored.</p>
<p><strong>Output formatting</strong></p>
<p>If <em>sents</em> is True (the default), sents containing a match word are
returned; otherwise just a word instead.</p>
<p>If <em>tagged</em> is True (the default), words are tagged in the form of
(word, pos, jyutping, rel); otherwise just word token strings.</p>
<p><em>by_files</em>: If False (the default), the return object is a list
encompassing search results for all files. If True, the return object
is dict(absolute-path filename: list of search results for that file)
instead.</p>
<p><strong>Others</strong></p>
<p><em>participant</em>: specify the participant(s) (default: all participants).</p>
</dd></dl>

<dl class="method">
<dt id="pycantonese.corpus.CantoneseCHATReader.update">
<code class="descname">update</code><span class="sig-paren">(</span><em>reader</em><span class="sig-paren">)</span><a class="headerlink" href="#pycantonese.corpus.CantoneseCHATReader.update" title="Permalink to this definition">¶</a></dt>
<dd><p>Combine the current CHAT Reader instance with <code class="docutils literal notranslate"><span class="pre">reader</span></code>.</p>
<p>reader : Reader</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="jyutping.html" title="Jyutping Romanization: Parsing and Conversion"
             >next</a> |</li>
        <li class="right" >
          <a href="stop_words.html" title="Stop Words"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">PyCantonese 2.2.0 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2014-2018, Jackson L. Lee | Documentation last updated on June 30, 2018.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.5.
    </div>
  </body>
</html>